package com.senno.service.impl;

import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.senno.entity.UserInfo;
import com.senno.mapper.UserInfoMapper;
import com.senno.service.UserInfoService;
import org.springframework.stereotype.Service;

import java.util.List;

//@Service 标识 service 是一个service层
@Service
public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo> implements UserInfoService {
    @Override
    public UserInfo selectByUserName(String username) {
        return baseMapper.selectByUserName(username);
    }

    @Override
    public Page<UserInfo> getUserList(int pageNo) {
        //pageNo:当前页  size: 10 代表每页显示10条数据
        Page<UserInfo> page = new Page<UserInfo>(pageNo, 10,"id");
        //是否为升序 ASC（ 默认： true ）
        page.setAsc(false);
        List<UserInfo> eList = baseMapper.selectPage(page, null);

        page.setRecords(eList);

        return page;
    }

    @Override
    public void addUser(UserInfo user) {
        baseMapper.addUser(user);
    }


}
